package com.zyong.design.pattern.interpret.case2;

/**
 * @program: zyong-design-pattern
 * @ClassName: Client
 * @author: zyong
 * @create: 2024-06-01 22:17
 */
public class Client {
    public static void main(String[] args) {
        Context ctx = new Context();

        Variable x = new Variable("x");
        Variable y = new Variable("y");

        Constant c = new Constant(true);

        ctx.assign(x, false);
        ctx.assign(y, true);

        Expression exp = new Or(new And(c, x), new And(y, new Not(x)));
        System.out.println("x=" + x.interpret(ctx));
        System.out.println("y=" + y.interpret(ctx));
        System.out.println(exp.toString() + "=" + exp.interpret(ctx));
    }
}
